###out:src/main/java/${config.fullControllerPackageName?replace(".","/")}/Framework${root.beanName}Controller.java
package ${config.fullControllerPackageName}.controller;

import com.zzb.framework.common.*;
import ${config.packageName}.entity.${root.beanName};
import com.zzb.framework.role.entity.IUser;
import ${config.packageName}.form.${root.beanName}SearchForm;
import ${config.packageName}.service.${root.beanName}Service;
import com.zzb.framework.frameworkcontroller.common.FrameworkBaseController;
import com.zzb.framework.common.BasePage;
import com.zzb.framework.common.BaseResponse;
import com.zzb.framework.common.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
* ${root.tableComment}controller
*/
@Controller
@RequestMapping("/framework/${root.beanName?uncap_first}")
public class Framework${root.beanName}Controller extends FrameworkBaseController {
    private static final Logger logger = LoggerFactory.getLogger(Framework${root.beanName}Controller.class);
    @Autowired
    private ${root.beanName}Service ${root.beanName?uncap_first}Service;

    /**${root.tableComment}管理首页*/
    @RequestMapping({"","/","/index"})
    public String index(){
        return "framework/${config.modulePackageName?replace(".","/")}/${root.beanName?uncap_first}/index";
    }

    /**${root.tableComment}列表json*/
    @RequestMapping("list")
    @ResponseBody
    public BasePage<${root.beanName}> list(${root.beanName}SearchForm ${root.beanName?uncap_first}SearchForm){
        return ${root.beanName?uncap_first}Service.queryPage(${root.beanName?uncap_first}SearchForm, ${root.beanName}.class);
    }

    /**${root.tableComment}表单页面*/
    @RequestMapping("form")
    public String form(String id, Model model){
        ${root.beanName} ${root.beanName?uncap_first};
        if(StringUtils.isEmpty(id)){
            ${root.beanName?uncap_first} = new ${root.beanName}();
        } else{
            ${root.beanName?uncap_first} = ${root.beanName?uncap_first}Service.get(id);
            if(${root.beanName?uncap_first} == null) ${root.beanName?uncap_first} = new ${root.beanName}();
        }
        model.addAttribute("${root.beanName?uncap_first}",${root.beanName?uncap_first});
        return "framework/${config.modulePackageName?replace(".","/")}/${root.beanName?uncap_first}/form";
    }

    /**${root.tableComment}保存*/
    @RequestMapping("/save")
    @ResponseBody
    public BaseResponse<${root.beanName}> save(${root.beanName} ${root.beanName?uncap_first} , HttpServletRequest request){
        try {
            IUser user = getCurrentUser(request);
            return ${root.beanName?uncap_first}Service.save${root.beanName}(${root.beanName?uncap_first}, user);
        } catch (ServiceException e) {
            e.printStackTrace();
            return new BaseResponse<>(BaseResponse.FAIL,e.getMessage());
        }
    }

    /**${root.tableComment}删除*/
    @RequestMapping("/delete")
    @ResponseBody
    public BaseResponse delete(String id,HttpServletRequest request){
        try {
            return ${root.beanName?uncap_first}Service.delete${root.beanName}(id,getCurrentUser(request));
        } catch (ServiceException e) {
            e.printStackTrace();
            return new BaseResponse(BaseResponse.FAIL,e.getMessage());
        }
    }

    /**${root.tableComment}开启*/
    @RequestMapping("/open")
    @ResponseBody
    public BaseResponse open(String id ,HttpServletRequest request){
        try {
            return ${root.beanName?uncap_first}Service.recovery(id,getCurrentUser(request));
        } catch (ServiceException e) {
            e.printStackTrace();
            return new BaseResponse(BaseResponse.FAIL,e.getMessage());
        }
    }

    /**${root.tableComment}屏蔽*/
    @RequestMapping("/deny")
    @ResponseBody
    public BaseResponse deny(String id ,HttpServletRequest request){
        try {
            return ${root.beanName?uncap_first}Service.trash(id,getCurrentUser(request));
        } catch (ServiceException e) {
            e.printStackTrace();
            return new BaseResponse(BaseResponse.FAIL,e.getMessage());
        }
    }

}
